package com.wly.ui.effect
{
	import flash.display.Sprite;
	import flash.text.TextField;
	
	import gs.TweenMax;
	
	public class ScoreEffect extends Sprite
	{
		private var _tfScore:TextField;
		private var _tw:TweenMax;
		
		private const duration:Number = 2;
		private const MOVE_H:Number   = 50;
		
		public function ScoreEffect()
		{
			super();
			
			_tfScore = getChildByName("tfScore") as TextField;
		}
		
		public function setScore(val:int):void
		{
			_tfScore.text = val.toString();
		}
		
		public function playEffect():void
		{
			var startY:Number = y;
			_tw = TweenMax.to(this, 3, {alpha:0, y:startY-MOVE_H, onComplete:onPlayComplete});
		}
		
		public function onPlayComplete():void
		{
			if(_tw)
			{
				_tw.clear();
				_tw = null;
			}
			
			if(this.parent)
			{
				parent.removeChild(this);
			}
		}
	}
}